<template>
  <div class="courseExamination">
    <el-breadcrumb separator="/" class="breadcrumb-bottom">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>课程管理</el-breadcrumb-item>
      <el-breadcrumb-item>排课审核</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row :gutter="20" class="mb-12">
      <el-col :span="4">
              <el-select v-model="form.majorID" placeholder="请选择专业" class="max-width">
               <el-option
                  v-for="item in majorList"
                  :label="item.majorName"
                  :value="item.majorID">
               </el-option>
              </el-select>
      </el-col>
      <el-col :span="4">
        <el-row>
          <el-col :span="11">
            <el-date-picker
              type="year"
              placeholder="开始学年"
              v-model="startYear"
              class="max-width"
              @change="getYear">
            </el-date-picker>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">
            <el-date-picker
              type="year"
              placeholder="结束学年"
              v-model="endYear"
              class="max-width">
            </el-date-picker>
          </el-col>
        </el-row>
      </el-col>
      <el-col :span="4">
        <div class="overflow-clear">
          <el-button type="primary" class="add-pd-26 float-right" @click="res">搜索</el-button>
        </div>
      </el-col>
    </el-row>
    <hr>
    <el-table
      :data="courseInfo"
      style="width: 100%">
      <el-table-column
        prop="majorName"
        label="专业"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="academicYear"
        label="学年"
        min-width="120">
      </el-table-column>
     
      <el-table-column
        prop="isCheck"
        label="审核情况"
        min-width="120">
      </el-table-column>
      <el-table-column
        label="排课结果"
        min-width="120">
        <template scope="scope">
          <el-button type="text" @click="CheckCourseArrangement(scope.row.coursesArrangeID)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="paging">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'courseExamination',
    data() {
      return {
        form: {
          majorID: '',
          enrollmentTime:'',
          academicYear: '',
          term: ''
        },
        courseInfo: [],
        majorList:[],
        academicYear: '',
        startYear: '',
        endYear: ''
      }
    },
    created () {
		this.res();
		this.getMajor();
    },
    methods: {
    	getMajor(){
        		this.$http.get(`http://localhost:8080/TeachingMIS/common/getMajorList`)
		          .then((res) => {
		            console.log(res)
		            this.majorList = res.body
		          }, (err) => {
		            // 响应错误回调
		            //console.log(err)
		          })
      		},
      res() {
        this.$http.post(`http://localhost:8080/TeachingMIS/courseArrange/getArrangeDetailList`, this.form).then((res) => {
		          // 响应成功回调
		          console.log(res.body)
		          this.courseInfo = res.body.arrangeList;
		        }, (err) => {
		          // 响应错误回调
		          console.log("服务器异常！");
		        })
      },
      getYear(val){
        this.endYear = (parseInt(val) + 1).toString()
        this.form.academicYear = val + '-' + this.endYear
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.currentPage = val;
        console.log(`当前页: ${val}`);
      },
      searchCourse: function () {
        this.form.majorName = this.form.newMajorName
        this.form.grade = this.form.newGrade
        this.form.academicYear = this.form.newAcademicYear
      },
      CheckCourseArrangement(coursesArrangeID){
        this.$router.push({path: 'CheckCourseArrangement', query: {coursesArrangeID: coursesArrangeID}})
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .add-pd-26 {
    padding-left: 1.6em;
    padding-right: 1.6em;
  }

</style>
